/*
 * @Author: liuxiao
 * @Date: 2023-09-05 07:24:49
 * @Last Modified by: liuxiao
 * @Last Modified time: 2023-11-12 00:46:55
 * 统一管理用户相关的接口
 */

import request from '@/utils/request'
import { loginFormData, loginResponseData, userInfoResponseData } from './type'

//统一接口管理
enum API {
  LOGIN_URL = '/yyx/admin/login',
  USERINFO_URL = '/api//admin/acl/index/info',
  LOGOUT_URL = '/api//admin/acl/index/logout',
  TEST_URL = '/api/loginTest'
}

//暴露请求函数
//登录接口方法
// export const reqLogin = (data: loginFormData) => {
//   //这里第二个loginResponseData是约束返回数据的TS类型
//   return request.post<any, loginResponseData>(API.LOGIN_URL, data)
// }

//获取用户信息接口方法
export const reqUserInfo = () =>
  request.get<any, userInfoResponseData>(API.USERINFO_URL)

//退出登录
export const reqLogout = () => request.post<any, any>(API.LOGOUT_URL)

//测试登录接口
export const reqTest = () => request.post(API.TEST_URL)

//登录接口方法（新）
export const reqLogin = (data: loginFormData) => {
  return request<any, loginResponseData>({
    method: 'POST',
    url: API.LOGIN_URL,
    data: data
  })
}
